<template>
	<view class="page mine">
		<view class="content" @click="onModifyInfo()">
			<head-image :name="userInfo.nickName" :url="userInfo.headImage" :size="160"></head-image>
			<view class="info-item">
				<view class="info-primary">
					<text class="info-username">
						{{userInfo.userName}}{{}}
					</text>
					<text v-show="userInfo.sex==0" class="iconfont icon-man" color="darkblue"></text>
					<text v-show="userInfo.sex==1" class="iconfont icon-girl" color="darkred"></text>
				</view>
				<text style="  color: #687787;  font-size:14px;">
					用户姓名 ：{{userInfo.nickName}}
				</text>
				<text style="  color: #687787;  font-size:14px;">
					签名 ：{{userInfo.signature}}
				</text>
			</view>
			<view class="info-arrow">></view>
		</view>
		<view class="line"></view>
		<view class="btn-group">
			<button class="btn" type="primary" @click="meet()" v-if="createIf">会议</button>
			<button class="btn" type="primary" @click="onModifyPassword()">修改密码</button>
			<button class="btn" type="primary" plain @click="onQuit()">退出</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				createIf: false, //是否创建会议
			}
		},
		methods: {
			//app打开手机上的浏览器
			openBrowser(url) {
				if (plus.os.name.toLowerCase() === 'android') {
					plus.runtime.openURL(url, null, function(error) {
						console.error('打开浏览器失败: ' + error.message);
					});
				} else {
					// iOS或其他平台的处理
					plus.runtime.openURL(url);
				}
			},
			meet() {
				//手机浏览器版的使用
				//window.open('https://61.55.135.66:9443/')
				//手机app版使用
				this.openBrowser('https://61.55.135.66:9443')
				//this.openBrowser('https://www.baidu.com')
			},
			onModifyInfo() {
				uni.navigateTo({
					url: "/pages/mine/mine-edit"
				})
			},
			onModifyPassword() {
				uni.navigateTo({
					url: "/pages/mine/mine-password"
				})
			},
			onQuit() {
				uni.showModal({
					title: '确认退出?',
					success: (res) => {
						if (res.confirm) {
							getApp().exit()
						}
					}
				});
			},
			//调用权限列表
			getPermission() {
				let array = uni.getStorageSync("permissionList");
				const elementToCheck = "1020";
				// 使用includes方法判断 1010 创建群组 1020 创建会议
				this.createIf = array.includes(elementToCheck);
			}
		},
		computed: {
			userInfo() {
				return this.$store.state.userStore.userInfo;
			}
		},
		mounted() {
			//加载权限
			this.getPermission();
		},


	}
</script>

<style scoped lang="scss">
	.mine {
		.content {
			height: 200rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx;

			.info-item {
				display: flex;
				align-items: flex-start;
				flex-direction: column;
				padding-left: 40rpx;
				flex: 1;

				.info-primary {
					display: flex;
					align-items: center;

					.info-username {
						font-size: 40rpx;
						font-weight: 400;
						line-height: 50px;
					}

					.icon-man {
						margin-left: 10px;
						color: #007aff;
					}

					.icon-girl {
						margin-left: 10px;
						color: #ff6600;
					}
				}
			}

			.info-arrow {
				width: 50rpx;
				font-size: 30rpx;
				font-weight: 500;
				color: #666666;
			}
		}

		.line {
			margin: 20rpx;
			border-bottom: 1px dashed #ddd;
		}

		.btn-group {
			margin: 100rpx;

			.btn {
				margin-top: 20rpx;
			}

		}
	}
</style>